$(function() {
	admin.cirlceTopic.init();
});
Namespace('admin.cirlceTopic', {
	init : function() {
		easyui.util.initDatagrid('#datagrid', {
			onDblClickRow : function() {
			}
		});
	},
	query : function() {
		if (!$('#query-form').form('validate'))
			return;
		var data = $('#query-form').form('jsonObject');
		$('#datagrid').datagrid('load', data);
	},
	detail:function(id) {
		if (id != null) {
			top.addTab(id,'详情', contextPath+'/circle/topic/detail?id=' + id);
		}
	},
	doTop4Topic: function (id) {
		var tip = "确定置顶吗";
		$.messager.confirm('信息提示', tip, function (success) {
			if (!success) {
				return;
			}
            var url = contextPath + '/circle/topic/doTop4Topic';
			$('#datagrid').datagrid('loading');
			$.post(url, {'id': id}, function (result) {
				$('#datagrid').datagrid('loaded');
				if (result.code == 1) {
					top.showInfo('操作成功');
					var pageopt = $('#datagrid').datagrid('getPager').data("pagination").options;
					//console.log(pageopt.pageNumber);
                    admin.cirlceTopic.query();
				} else {
					top.showInfo(result.msg);
				}
			});

		});
	},
	undoTop4Topic: function (id) {
		var tip = "确定取消置顶吗";
		$.messager.confirm('信息提示', tip, function (success) {
			if (!success) {
				return;
			}
            var url = contextPath + '/circle/topic/undoTop4Topic';
			$('#datagrid').datagrid('loading');
			$.post(url, {'id': id}, function (result) {
				$('#datagrid').datagrid('loaded');
				if (result.code == 1) {
					top.showInfo('操作成功');
					var pageopt = $('#datagrid').datagrid('getPager').data("pagination").options;
					//console.log(pageopt.pageNumber);
                    admin.cirlceTopic.query();
				} else {
					top.showInfo(result.msg);
				}
			});

		});
	},
	showTopic: function (id) {
        var url = contextPath + '/circle/topic/showTopic';
		$('#datagrid').datagrid('loading');
		$.post(url, {'id': id}, function (result) {
			$('#datagrid').datagrid('loaded');
			if (result.code == 1) {
				top.showInfo('操作成功');
				var pageopt = $('#datagrid').datagrid('getPager').data("pagination").options;
				//console.log(pageopt.pageNumber);
                admin.cirlceTopic.query();
			} else {
				top.showInfo(result.msg);
			}
		});
	},
	hideTopic: function (id) {
        var url = contextPath + '/circle/topic/hideTopic';
		$('#datagrid').datagrid('loading');
		$.post(url, {'id': id}, function (result) {
			$('#datagrid').datagrid('loaded');
			if (result.code == 1) {
				top.showInfo('操作成功');
				var pageopt = $('#datagrid').datagrid('getPager').data("pagination").options;
				//console.log(pageopt.pageNumber);
                admin.cirlceTopic.query();
			} else {
				top.showInfo(result.msg);
			}
		});
	}
});